#include <iostream>
using namespace std;

class Person{
protected:
    string name;
    string id;
    string birth;
    string sex;

public:
    Person(){
        this->name = "";
        this->id = "";
        this->birth = "";
        this->sex = "";
    }
    ~Person(){
        cout << "Person "<<this<<" destruction" << endl;
    }
    void setName(string name){
        this->name=name;
    }
    void setId(string id){
        this->id=id;
    }
    void setBirth(string birth){
        this->birth=birth;
    }
    void setSex(string sex){
        this->sex=sex;
    }
    string toString(){
        return name+",id("+id+"), birth("+birth+"), "+sex;
    }

    void display(){
        cout<<"人："+toString()<<endl;
    }
};

class Student: public Person{
protected:
    string major;
    string str_class;

public:
    Student(){
       this->major = "";
       this->str_class = ""; 
    }
    ~Student(){
        cout << "Student "<<this<<" destruction" << endl;
    }
    void setMajor(string major){
        this->major=major;
    }
    void setClass(string str_class){
        this->str_class=str_class;
    }

    void display(){
        cout<<"学生："+Person::toString()+", "+major+"专业, 班级"+str_class<<endl;
    }
};

class Teacher: public Person{
protected:
    string subject;
    string degree;

public:
    Teacher(){
       this->subject = "";
       this->degree = ""; 
    }
    ~Teacher(){
        cout << "Teacher "<<this<<" destruction" << endl;
    }
    void setSubject(string subject){
        this->subject=subject;
    }
    void setDegree(string degree){
        this->degree=degree;
    }
    void display(){
        cout<<"教师："+Person::toString()+", 课程为"+subject+", 学历"+degree<<endl;
    }
};

int main(){
    Student s=Student();
    Teacher t=Teacher();
    s.setName("张三");
    s.setId("000232");
    s.setBirth("19900102");
    s.setSex("男");
    s.setMajor("文学");
    s.setClass("2");
    s.display();

    t.setName("李四");
    t.setId("023413");
    t.setBirth("19800104");
    t.setSex("男");
    t.setSubject("C++");
    t.setDegree("博士");
    t.display();

    return 0;
}